#include <iostream>
#include <forward_list>
using namespace std;

int main()
{
    forward_list<int> list = {3, 4, 45, 6};
    list.push_front(1);
    auto ite = list.end();

    int count = distance(begin(list), end(list));
    cout<<"count:"<<count<<endl;

    forward_list<string> data_ {"one","null","three","four","null","six","seven"};
    //begin_iter_ 可以单向移动
    auto begin_iter_ = begin(data_);
    //end_iter_ 不可以移动
    forward_list<string>::iterator end_iter_ = end(data_);
    int len_data_ = distance(begin_iter_,end_iter_);
    cout<<"data_ : "<<len_data_<<endl;
    for(auto d : data_){
        cout<<d<<" ";
    }
    cout<<endl;
    cout<<"move begin_iter_ :"<<endl;
    //使用 advance() 移动 begin_iter_
    int step = 2;
    advance(begin_iter_,step);
    len_data_ = distance(begin_iter_,end_iter_);
    cout<<"end_iter_ - begin_iter_ = "<<len_data_<<endl;
    // 将 begin_iter_ 和 end_iter_ 之间的内容赋值给 data
    forward_list<string> data(begin_iter_,end_iter_);
    auto begin_iter = begin(data);
    forward_list<string>::iterator end_iter = end(data);
    // 得到 data 的长度
    int len_data = distance(begin_iter,end_iter);
    cout<<"data : "<<len_data<<endl;
    for(auto d : data){
        cout<<d<<" ";
    }
    cout<<endl<<"data : "<<endl;
    auto iter = begin(data);
    step = 3;
    advance(iter,step);
    cout<<"the "<<(step+1)<<"th elememt is "<<*iter<<endl;
    return 0;

}